(function() {
	var ue;
	var oldDIVWidth;
	var userRight;
	/*$("#avatar").error(function() {
		$(this).attr("src", "../img/loading.gif");
		$(this).error = null;
	});
	$("#avatarbig").error(function() {
		$(this).attr("src", "../img/loading.gif");
		$(this).error = null;
	});*/
	/*$("#backloadingimg").on('click',function(){
		jQuery("#avatarbig").prop("src","");
	});*/
	$("body").on("click", ".extendimg", function (){
		jQuery("#avatarbig").prop("src","");
        var id=$(this).attr('id');
        if(id!="bimg"){
        	jQuery("#avatarbig").prop("src",$("#"+id+"_img").attr("src"));
        } else{
        	jQuery("#avatarbig").prop("src",$("#avatar").attr("src"));
        }
        
	});
	///游客登录
    jQuery('#subtnForVisitors').on('click', function () {
		    var name = "Visitors";
			var password ="visitors";
			var smsCode =jQuery("#smsCode").val();
			var identify = jQuery("#identify").val();
			var urladress =jQuery("#url").val();
				var url = window.rootPath + '/ui/login/msubmit';
				jQuery("input").attr("disabled", true);
				jQuery(".login").attr("disabled", true);
				jQuery(".set").attr("disabled", true);
				
				var data = {
					"accountName" : name,
					"password" : sha256_digest(password),
					"smsCode" : smsCode
				}
				jQuery.ajax({
					url : encodeURI(url),
					type : "post",
					dataType : "json",
					data : JSON.stringify(data),
					contentType : "application/json;charset=UTF-8",
					success : function(data) {
						jQuery("input").attr("disabled", false);
						jQuery(".login").attr("disabled", false);
						jQuery(".set").attr("disabled", false);
						if (data.code == 0) {
							jQuery('#error').html('用户名或密码错误');
							/*createCode();
							jQuery("#loginCode").val('');*/
						} else if (data.code == 1) {
							/*var picture = data.picture;
							localStorage.setItem('picture', picture);
							localStorage.setItem('name', name);
							localStorage.setItem('userId', data.userId);	*/	
							
							location.reload();
						}
						else if (data.code == 3) {
						
							/*message(data.message);*/
						}
						else if(data.code == 99){//验证码失败
							/*jQuery('#error').html(data.message);*/
						}
					}
				});
    });
	///用户登录
    jQuery('#subtnForUser').on('click', function () {
		    var name = jQuery("#user").val();
			var password =jQuery("#pwd").val();
			var smsCode =jQuery("#smsCode").val();
			var identify = jQuery("#identify").val();
			var urladress =jQuery("#url").val();
				var url = window.rootPath + '/ui/login/msubmit';
				jQuery("input").attr("disabled", true);
				jQuery(".login").attr("disabled", true);
				jQuery(".set").attr("disabled", true);
				
				
				$("#popupWait").popup();
        		$("#popupWait").popup('open');
				/*jQuery('#loadingImage').show();*/
				var data = {
					"accountName" : name,
					"password" : sha256_digest(password),
					"smsCode" : smsCode
				}
				jQuery.ajax({
					url : encodeURI(url),
					type : "post",
					dataType : "json",
					data : JSON.stringify(data),
					contentType : "application/json;charset=UTF-8",
					success : function(data) {
						jQuery("input").attr("disabled", false);
						jQuery(".login").attr("disabled", false);
						jQuery(".set").attr("disabled", false);
						/*jQuery('#loadingImage').hide();*/
						$("#popupWait").popup('close');
						if (data.code == 0) {
							jQuery('#error').html('用户名或密码错误');
							/*createCode();
							jQuery("#loginCode").val('');*/
						} else if (data.code == 1) {
							/*var picture = data.picture;
							localStorage.setItem('picture', picture);
							localStorage.setItem('name', name);
							localStorage.setItem('userId', data.userId);	*/	
							
							location.reload();
						}
						else if (data.code == 3) {
						
							/*message(data.message);*/
						}
						else if(data.code == 99){//验证码失败
							/*jQuery('#error').html(data.message);*/
						}
					}
				});
    });
$("body").on("click", ".menu-scd-click", function (){
	        var id=$(this).attr('id');
	        var s=$(this).attr("href");
	        $("#menu-scd").popup("close");
	        if(id=="goTop"){
	        	$('html,body').animate({scrollTop: '0px'}, 1000);return false;
	        }else if(id=="goBottom"){
	        	$('html,body').animate({scrollTop:$(document).height()+'px'},1000);return false;
	        }/*else if(id=="goaAnds"){
	        	$('html,body').animate({scrollTop: '0px'}, 1000);
	        }*/
		});
	$("body").on("click", ".menuClick", function (){
		$("#menu-scd-list").empty();
		/*alert($(window).height()); //浏览器当前窗口可视区域高度 
		alert($(document).height()); //浏览器当前窗口文档的高度 
		alert($(document.body).height());//浏览器当前窗口文档body的高度 
		alert($(document.body).outerHeight(true));*/
		var id=$(this).attr("id");
		if(id=="menu-login"){
			$("#popupLoginSelect").popup("open");
		}else{
			if(id=="menu-home"){
				var contenthtml='<li class="ui-li-icon ui-corner-none" data-icon="false"><a href="#pagetwo" data-transition="slide" id="goaAnds">评价</a></li>'
				+'<li class="ui-li-icon ui-corner-none" data-icon="false"><a href="#" class="menu-scd-click" id="goTop">返回顶部</a></li>'
				+'<li class="ui-li-icon ui-corner-none" data-icon="false"><a href="#" class="menu-scd-click" id="goBottom">返回底部</a></li>';
				$("#menu-scd-list").append(contenthtml);
				$("#menu-scd-list").listview('refresh');
				}else{
					var contenthtml="";
					
					for(var i=0;i<userRight.length;i++){
						if(userRight[i].mobile!=undefined&&userRight[i].mobile=="true"&&userRight[i].target!="#"&&userRight[i].parentId==id){
							var url='javascript: ;';
							var isGo=false;
							var menuType="menuClick";
							var icon="home";
							var dataajax ='';
							if(userRight[i].icon!=undefined&&userRight[i].icon!=""){
								icon=userRight[i].icon;
							}
						    url=window.rootPath+userRight[i].target+"?device=mobile&identify="+$("#identify").val();
						    isGo=true;
						    menuType="menu-scd-click-bak";
						    dataajax ='data-ajax="false"';
							    
						 contenthtml +='<li class="ui-li-icon ui-corner-none" data-icon="false"><a href="'+url+'" data-icon="'+icon+'" class="'+menuType+'" id="'+userRight[i].id+'" '+dataajax+'>'+userRight[i].moduleName+'</a></li>';
						}
					}
					if(contenthtml!=""){
						$("#menu-scd-list").append(contenthtml);
						$("#menu-scd-list").listview('refresh');
					}
				}
				
				/*var id=$(this).attr("id");*/
				openGroupMenu(id,"menu-scd","menu-scd-arrow");
		}
		});
	/*计算菜单位置*/
	function openGroupMenu(controller,controllerscd,controllerscdarrow){
	    var left, top;
	    var rect = document.getElementById(controller).getBoundingClientRect();//controller.getBoundingClientRect();
	    var winrect =document.getElementById(controllerscd).getBoundingClientRect();//controllerscd.getBoundingClientRect();
	    left = rect.left+ winrect.width/2;
	    top = rect.top-winrect.height/2+$(document).scrollTop();
	    $("#"+controllerscd).popup("open", {
	                x:left,
	                y:top});
	    /*计算三角型的位置*/
	    winrect =document.getElementById(controllerscd).getBoundingClientRect();
	    document.getElementById(controllerscdarrow).style.left = (rect.left + rect.width/2 - winrect.left) + "px";
	};
	
	$(document).ready(function() {
		
		/*
		 * ue = UE.getEditor('editor',{ toolbars: [] ,elementPathEnabled : false
		 * //是否启用元素路径，默认是true显示 ,wordCount:false //是否开启字数统计 ,readonly:true });
		 */
		/*var edit = $("#displayEdit").val();
		var check = $("#displayCheck").val();
		var inspection=$("#displayInspection").val();
		var kitchen=$("#displayKitchen").val();
		
		$('#myedit').css('display', edit);
		$('#myinspection').css('display', inspection);
		$('#mycheck').css('display', check);
		$('#mykitchen').css('display', kitchen);*/
		
		$('#stardivT').raty();
		$('#stardivT').raty({
			number : 5,
			targetType: 'hint',
			hints: ['非常不满意', '不满意', '一般', '满意', '非常满意'],
			target: '#stardivT-hint',
			targetKeep: true,
			targetText: '请选择评分',
			size:$("#myTableT").attr("width")-5,
			cancel : true,
			cancelHint : '请选择评分'
		});
		getData();
		initBussinessContent();
		// 初始化巡检历史记录
		initPartInspections();
		// 初始化举报信息
		initPartAccusations();
		//初始化潲水搜集信息
		initPartKitChenwastes();
		
	});
	/*// 编辑商户信息
	jQuery('#myedit').on(
			'click',
			function() {
				window.location = window.rootPath
						+ "/ui/bussinessEdit?device=mobile&&identify="
						+ $("#identify").val();
			});
	// 核检商户信息
	jQuery('#mycheck').on(
			'click',
			function() {
				window.location = window.rootPath
						+ "/ui/bussinessCheck?device=mobile&&identify="
						+ $("#identify").val();
			});
	// 巡检商户信息 
	jQuery('#mykitchen').on(
			'click',
			function() {
				window.location = window.rootPath
						+ "/ui/kitchenwaste?device=mobile&&identify="
						+ $("#identify").val();
			});
	// 巡检商户信息
	jQuery('#myinspection').on(
			'click',
			function() {
				window.location = window.rootPath
						+ "/ui/bussinessInspection?device=mobile&&identify="
						+ $("#identify").val();
			});*/
	// /编辑
	jQuery('#saveBtnT').on(
			'click',
			function() {
				var temp = $('#stardivT').raty('score');
				if (temp == undefined) {
					temp = 0;
				}
				var url = window.rootPath
						+ '/ui/bussinessmain/saveBusinessAccusationWithFile';
			var	d = {
					"accusationType" : $("#accusationType").val(),
					"accusationScale" : temp * 20,
					"accusationReason" : $("#accusationReason").val(),
					"businesssellerBaseInfo" : $("#identify").val(),
					"telephone" : $("#telephone").val()
					
				};
				$.ajaxFileUpload({
					url : url,
					secureuri : false,// 是否需要安全协议
					fileElementId : 'file_upload',// 文件上传的Id属性
					dataType : 'JSON',
					data : d,
					success : function(result, status) {
						getData();
					}
				});

				/*jQuery.ajax({
					type : 'post',
					url : encodeURI(url),
					data : JSON.stringify(d),
					dataType : 'json',
					contentType : 'application/json;charset=utf-8',
					success : function(data) {
						if (data.code == -1) {
							 message(data.message); 
						} else {
							
							 * $("#popupView").popup();
							 * $("#popupView").popup('open');
							 
							 $("#test").trigger("click"); 
						}
						getData();
					}
				});*/

			});

	function initPartAccusations() {
		var identify = $("#identify").val();

		$.ajax({
			url : window.rootPath + '/ui/bussinessmain/listPartAccusations/'
					+ identify,
			dataType : 'json',
			type : 'get',
			success : function(result) {

				var accusations = result.data.accusations;

				if (result.code == 1) {

					buildAccusations(accusations, "#accusations");

				}
			}
		});
	}
	;
	function initPartKitChenwastes(){
		//09e98f7a-1d61-4b9d-a101-a1f86cc25bd1
		var bussinessId = $("#identify").val();
		
		$.ajax({
			url : window.rootPath + '/ui/bussinessmain/listPartwastes/'
					+ bussinessId,
			dataType : 'json',
			type : 'get',
			success : function(result) {

				var wastes = result.data.wastes;

				if (result.code == 1) {

					buildWastes(wastes);

				}
			}
		});
	};
	function buildWastes(pageInfo){
		var str="#kitchenwastes";
		if (pageInfo.length == 0) {
			var contenthtml = '<li><h2 style="color:blue">暂无搜集信息</h2></li>';
			$(str).append(contenthtml);
			$(str).listview('refresh');
		}
		
		for (var i = 0; i < pageInfo.length; i++) {
//			var contenthtml='<br/><div class="div1">'
//				+'<a data-transition="slide" defineId="'+pageInfo[i].id+'" id="'+pageInfo[i].id+'"><div class="div-time"><div style="margin-left:20px;">'
//				+moment(pageInfo[i].createTime).format('YYYY-MM-DD HH:mm')
//				+'</div></div></a><br/>'
//			    +'<div class="div-type">废物量:'+pageInfo[i].waste+'kg</div><div class="div-type">油&nbsp;&nbsp;&nbsp;量:'+pageInfo[i].wasteOil+'kg</div><br/>';
//				
//			contenthtml+='<div style="overflow: auto;padding-top:0;margin-left:20px;">'
//			+'<div class="div-inline"><p style="margin:0;">人员:'+pageInfo[i].checkPerson.name+'</p></div>'
//			+'<div class="div-inline"><p style="margin:0;">电话:'+pageInfo[i].checkPerson.contactType+'</p></div></div>'
//			+'</div>';
//			$(str).append(contenthtml);
			
			var infoId=pageInfo[i].id;
			var memo1= moment(pageInfo[i].createTime).format('YYYY-MM-DD HH:mm');
			var memo2='废物量:'+pageInfo[i].waste+'kg';
			var memo3='油&nbsp;&nbsp;&nbsp;量:'+pageInfo[i].wasteOil+'kg';
			var memo4='人员:'+pageInfo[i].checkPerson.name;
			var memo5='电话:'+pageInfo[i].checkPerson.contactType;
			$(str).setListViewContent(infoId,memo1,memo2,memo3,memo4,memo5);
		}
	};
	function buildAccusations(info, str) {

		if (info.length == 0) {
			var contenthtml = '<li><h2 style="color:blue">暂无考核信息</h2></li>';
			$(str).append(contenthtml);
			$(str).listview('refresh');
		}

		for (var i = 0; i < info.length; i++) {

			var purl = info[i].pictureAddr;// 没有上传图片

			if (purl == undefined || purl == "") {
				purl = "img/nopicture.png";
			}
//			purl = rootPath + "/" + purl;
			
			var scaleDes="'非常不满意', '不满意', '一般', '满意', '非常满意'";
			
			if(info[i].accusationScale<20){
				scaleDes='非常不满意';
			}else if(info[i].accusationScale<40){
				scaleDes='不满意';
			}else if(info[i].accusationScale<60){
				scaleDes='一般';
			}else if(info[i].accusationScale<80){
				scaleDes='满意';
			}else if(info[i].accusationScale>=80){
				scaleDes='非常满意';
			}
			
//			var contenthtml ="<li><table><tr>" +
//						'<td width="30%"><a href="#pop" data-rel="popup" data-position-to="window" id="'+info[i].id+'" class="extendimg" data-transition="fade"><img id="'+info[i].id+'_img" width="100%" src="'+purl+'"/></a></td><td><div class="div-type">' 
//			            +"<font >评价类型:&nbsp;"+ info[i].accusationType.title + "</font><br/>" +
//							"<font >评价原因:&nbsp;"+ info[i].accusationReason + "</font><br/>" +
//							"<font>满意度:&nbsp;"+ scaleDes + "</font><br/>" +
//							/*"<font>评价人:&nbsp;"+info[i].user.name+"</font><br/>"+
//							"<font>联系电话:&nbsp;"+info[i].user.contactType+"</font><br/>"+*/
//							"<font>时间:&nbsp;"+ moment(info[i].accusationDate).format('YYYY-MM-DD HH:mm')+"</font>" +
//						"</div></td></tr></table></li>";

			var infoId = info[i].id;
			var pic = purl;
			var memo1 = "评价类型:&nbsp;"+ info[i].accusationType.title;
			var memo2 = "评价原因:&nbsp;"+ info[i].accusationReason;
			var memo3 = "满意度:&nbsp;"+ scaleDes;
			var memo4 = "时间:&nbsp;"+ moment(info[i].accusationDate).format('YYYY-MM-DD HH:mm');
			
			$(str).setListViewContent(infoId,pic,memo1,memo2,memo3,memo4);

		}
		$(str).listview('refresh');
	}
	;
	function initPartInspections() {
		var identify = $("#identify").val();

		$.ajax({
			url : window.rootPath + '/ui/bussinessmain/listPartInspections/'
					+ identify,
			dataType : 'json',
			type : 'get',
			success : function(result) {

				var inspections = result.data.inspections;

				if (result.code == 1) {

					buildInspections(inspections, "#inspections");

				}
			}
		});
	};
	function buildInspections(pageInfo, str) {
		if (pageInfo.length == 0) {
			var contenthtml = '<li><h2 style="color:blue">暂无巡检信息</h2></li>';
			$(str).append(contenthtml);
			$(str).listview('refresh');
		}
		
		for (var i = 0; i < pageInfo.length; i++) {
			var tempHtml ='';
			if(pageInfo[i].details!=null){
				for(var j=0;j<pageInfo[i].details.length;j++){
					var temp = pageInfo[i].details[j].inspectOpt.title;
					if(temp.length>10){
						temp =temp.substring(0,12)+"...";
					}
					if(j<pageInfo[i].details.length-1){
						tempHtml += temp +'、';
					}else{
						tempHtml += temp;
					}
				}
			}
			var purl = pageInfo[i].pictureAddr;// 没有上传图片
			if (purl == undefined || purl == "") {
				purl = "img/nopicture.png";
			}
//			purl = window.rootPath + "/" + purl;
			
//			var contenthtml='<li><a style="background-color:#FFFFFF" href="#detailInspectPanel" data-transition="slide" class="hrefClick" defineId="'+pageInfo[i].id+'" id="'+pageInfo[i].id+'">'
//			+ '<div class="listViewImg-D">'
//			+ '<img id="'+pageInfo[i].id+'_img" src="'+purl+'"/>'	
//			+ '</div>'
//			+ '<div class="listViewContent-D">'
//			+ '<P class="listViewTitle-D">'+moment(pageInfo[i].inspectDate).format('YYYY-MM-DD HH:mm')+'</p>'
//			+ '<p class="listViewMemo-D">总体评价:'+pageInfo[i].inspectCondition.title +'</p>'
//			+ '<p class="listViewMemo-D">'+tempHtml +'</p>'
//			+ '<p class="listViewFoot-D">巡检人:'+pageInfo[i].user.name+'</p>'
//			+ '<p class="listViewFoot-D">电话:'+pageInfo[i].user.contactType+'</p>'
//			+ '</div>';
//			contenthtml+='</a></li>';
//			$(str).append(contenthtml);
			var listView = $(str);
			var infoId = pageInfo[i].id;
			var pic = purl;
			var title = moment(pageInfo[i].inspectDate).format('YYYY-MM-DD HH:mm');
			var memo1 = '总体评价:'+pageInfo[i].inspectCondition.title;
			var memo2 = tempHtml;
			var foot1 = '巡检人:'+pageInfo[i].user.name;
			var foot2 = '电话:'+pageInfo[i].user.contactType;
			
			//setListViewContent(listView,infoId,pic,title,memo1,memo2,foot1,foot2);
			listView.setListViewContent(infoId,pic,title,memo1,memo2,foot1,foot2);
		}
		$(str).listview('refresh');
//		$(".ui-btn-icon-right").removeClass("ui-btn-icon-right");
	}
	
	//展示详细信息
	$("body").on("click",".hrefClick",function() {
		$("#xmxqList").empty();
		// 初始化面板信息
		var inspectId = $(this).attr("defineId");// 自定义的属性,方便id的传递

		$.ajax({
				url : window.rootPath
						+ '/ui/bussinessmain/findById/'
						+ inspectId,
			
				dataType : 'json',
				type : 'get',
				success : function(result) {
					if (result.code == 1) {
						var info = result.data.info;
						// 构建面板数据
						$("#bussinessName")
								.text(
										info.businesssellerBaseInfo.shopName);
						$("#bussiessAddr")
								.text(
										info.businesssellerBaseInfo.shopAdress);
						$("#bussinessMng")
								.text(
										info.businesssellerBaseInfo.managementPerson.name);
						$("#remarkI").text(info.remark);
						
						$("#inspectCondition").text(
								info.inspectCondition.title);
						
						$("#inspectDate").text(moment(info.inspectDate).format('YYYY-MM-DD HH:mm'));
						$("#inspectPerson").text(info.user.name);
						
						var imgUrl=info.pictureAddr;
						if(imgUrl==undefined||imgUrl==""){
							imgUrl="../img/nopicture.png";
						}else{
							imgUrl=window.rootPath+'/'+imgUrl;
						}
						$("#avatartI").attr("src",imgUrl);
						
						
						var list=info.details;
						
						var enr='';
						if(list==null||list.length==0){
							var  contenthtml =   '<tr><td colspan="2">'  
				                  +'<h2 style="color:blue">暂无巡检问题清单</h2>'  
				                  + '</tr></td>';  
				                  $("#xmxqList").append(contenthtml);
						}
						for (var i = 0; i < list.length; i++) {
							var purl=list[i].picAddr;
							if(purl==undefined||purl==""){
								purl="../img/nopicture.png";
							}else{
								purl=window.rootPath+'/'+purl;
							}
							
//							var  contenthtml ='<tr><td colspan="2" style="color: #999999; border-bottom: 2px solid #55B937 !important;"></td></tr>'
//							  +'<tr><td width="1%"><p style="color: #999999;">现场图片</p></td><td><a href="#pop" data-rel="popup" data-position-to="window" id="'+list[i].id+'" class="extendimg" data-transition="fade"><img id="'+list[i].id+'_img" width="30%" src="'+purl+'"/></a></td></tr>'  
//							  +'<tr><td><p style="color: #999999;">备注</p></td><td><p>'+list[i].remark+'</p></td></tr>' 
//			                  +'<tr><td><p style="color: #999999;">时间</p></td><td><p>'+moment(list[i].createTime).format('YYYY-MM-DD HH:mm')+'</p></td></tr>';
//			                  $("#xmxqList").append(contenthtml);
							
							var infoId = list[i].id;
			                var memo1 = "备注:"+list[i].remark;
			                var memo2 = "时间:"+moment(list[i].createTime).format('YYYY-MM-DD HH:mm');
			                $("#xmxqList").setListViewContent(infoId,purl,memo1,memo2);
						}
					}
				}
			});
		// 指向面板属性的id
		$(this).prop("href", "#detailInspectPage");

	});
	
	function getData() {
		var identify = $("#identify").val();

		var url = window.rootPath + '/ui/bussinessmain/getBussinesserInfo/'
				+ identify;
		jQuery
				.ajax({
					url : encodeURI(url),
					cache : false,
					type : "get",
					data : "",
					dataType : "json",
					contentType : 'application/json;charset=utf-8',// 解决返回数据中的中文乱码问题
					success : function(data) {
						//#动态添加菜单
						var contenthtml='<ul id="menu-list">'
						    +'<li><a href="javascript: ;" data-icon="home" class="menuClick"'
							+'id="menu-home">首页</a></li>'
							+'<li><a href="javascript: ;" data-icon="user" class="menuClick"'
							+'id="menu-login">登录</a></li>';
						userRight =data.modules;
						for(var i=0;i<data.modules.length;i++){
							if(data.modules[i].mobile!=undefined&&data.modules[i].mobile=="true"&&data.modules[i].menuLevel==1){//&&data.modules[i].menuLevel==1
								var url='javascript: ;';
								var isGo=false;
								var menuType="menuClick";
								var icon="home";
								var dataajax ='';
								if(data.modules[i].icon!=undefined&&data.modules[i].icon!=""){
									icon=data.modules[i].icon;
								}
								
								if(data.modules[i].target!="#"){
								    url=window.rootPath+data.modules[i].target+"?device=mobile&identify="+$("#identify").val();
								    isGo=true;
								    menuType="menu-scd-click-bak";
								    dataajax ='data-ajax="false"';
								}
								 contenthtml +='<li><a href="'+url+'" data-icon="'+icon+'" class="'+menuType+'" id="'+data.modules[i].id+'" '+dataajax+'>'+data.modules[i].moduleName+'</a></li>';
							}
						}
						 contenthtml+='</ul>';
						 $('#menu-bar').empty();
//						 $('#menu-bar').append(contenthtml);
						 $('#menu-bar').navbar('refresh');
						/*$("#menu-list").append(contenthtml);*/
						/*$("#menu-list").listview('refresh');*/
						$('#stardiv').raty();
						if (data.evaluate != undefined) {
							$("#evaluateScale").html(
									data.evaluate.evaluateScale + "分");
							$('#stardiv').raty({
								number : 5,
								readOnly : true,
								size:$("#btitle").attr("width")-5,
								score : data.evaluate.evaluateScale / 20.0
							});// evaluateLevel
						} else {
							$("#evaluateScale").html("-- 分");
							$('#stardiv').raty({
								number : 5,
								size:$("#btitle").attr("width")-5,
								readOnly : true,
								score : 0
							});
						}
						if (data.businesssellerBaseInfo != undefined) {
							var avatarUrl=data.businesssellerBaseInfo.pictureAdress;
							if(avatarUrl==undefined||avatarUrl==""){
								avatarUrl="../img/nopicture.png";
							}else{
								avatarUrl=window.rootPath+'/'+avatarUrl;
							}
							/*var avatarUrl = window.rootPath + '/a/' + 'avatar/'
									+ data.businesssellerBaseInfo.pictureAdress;*/
							/* jQuery("#avatar").prop("src","#"); */
							jQuery("#avatar").prop("src",
									avatarUrl + '?t=' + Math.random());
							/* jQuery("#avatarbig").prop("src","#"); */
							jQuery("#avatarbig").prop("src",
									avatarUrl + '?t=' + Math.random());

							$("#maintitle").html(
									data.businesssellerBaseInfo.shopName);
							$("#shopName").html(
									data.businesssellerBaseInfo.shopName);
							$("#shopNameT").html(
									data.businesssellerBaseInfo.shopName);
							if (data.businesssellerBaseInfo.infoState != undefined) {
								/* $("#infoState").html(data.businesssellerBaseInfo.infoState.title); */
								var path = "";
								if (data.businesssellerBaseInfo.infoState.title == '待认证') {
									path = "../img/authentication_in.png";
								} else if (data.businesssellerBaseInfo.infoState.title == '认证拒绝') {
									path = "../img/authentication_notaccess.png";
								} else if (data.businesssellerBaseInfo.infoState.title == '认证通过') {
									path = "../img/authentication_access.png";
								} else if (data.businesssellerBaseInfo.infoState.title == '初始化') {
									path = "../img/authentication_init.png";
								} else if (data.businesssellerBaseInfo.infoState.title == null) {
									path = "";
								}
								$("#infoState").attr('src', path);
							}

							$("#shopAdress").html(
									data.businesssellerBaseInfo.shopAdress);
							$("#areaMeasure").html(
									data.businesssellerBaseInfo.areaMeasure+" 平方米");
							$("#signPerson").html(
									data.businesssellerBaseInfo.signPerson);
							/*$("#signPersonPhone").html(
									data.businesssellerBaseInfo.signPersonPhone);*/
							$("#signPersonPhone").html("<a href='tel:"+data.businesssellerBaseInfo.signPersonPhone+"'>"+data.businesssellerBaseInfo.signPersonPhone+"</a>");
							$("#cleaningPerson").html(data.businesssellerBaseInfo.cleaningPerson);
							/*$("#cleaningPersonPhone").html(data.businesssellerBaseInfo.cleaningPersonPhone);*/
							$("#cleaningPersonPhone").html("<a href='tel:"+data.businesssellerBaseInfo.cleaningPersonPhone+"'>"+data.businesssellerBaseInfo.cleaningPersonPhone+"</a>");
							
							$("#managementRange")
									.html(
											data.businesssellerBaseInfo.managementRange);
							$("#memo").html(data.businesssellerBaseInfo.memo);
							if (data.businesssellerBaseInfo.bussinessLevel != undefined) {
								$('#area')
										.html(
												"管理单位:"
														+ data.businesssellerBaseInfo.bussinessLevel.levelName);
								$('#areaphone')
										.html(
												"联系电话:<a href='tel:"+data.businesssellerBaseInfo.bussinessLevel.phoneNumber+"'>"+data.businesssellerBaseInfo.bussinessLevel.phoneNumber+"</a>");
							
							if (data.businesssellerBaseInfo.bussinessLevel.manager!=null) {
								$('#areaMperson')
										.html(
												data.businesssellerBaseInfo.bussinessLevel.manager.name);
							}
							}
						}

						// $("#area").find("option:contains('"+data.areaInfo.title+"')").attr("selected",true);
						// jQuery('#area').val(data.areaInfo.id);
						// $("#areaMperson").find("option:contains('"+data.arreaManagementPerson.name+"')").attr("selected",true);
						// jQuery('#areaMperson').val(data.arreaManagementPerson.id);

						/*
						 * $("#managementPerson").html("管理人员:
						 * "+data.managementPerson.name);
						 */
					}
				})
	}
	;
	$("#file_upload").change(function () {
		/*alert(1);*/
	    var $file = $(this);
	    var fileObj = $file[0];
	    var windowURL = window.URL || window.webkitURL;
	    var dataURL;
	    var $img = $("#avatart");

	    if (fileObj && fileObj.files && fileObj.files[0]) {
	        dataURL = windowURL.createObjectURL(fileObj.files[0]);
	        $img.attr('src', dataURL);
	    } else {
	        dataURL = $file.val();
	        var imgObj = document.getElementById("preview");
	        // 两个坑:
	        // 1、在设置filter属性时，元素必须已经存在在DOM树中，动态创建的Node，也需要在设置属性前加入到DOM中，先设置属性在加入，无效；
	        // 2、src属性需要像下面的方式添加，上面的两种方式添加，无效；
	        imgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
	        imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = dataURL;

	    }
	});
	jQuery('#fileclick').on('click', function () {
		return  $("#file_upload").click();
	});
	function initBussinessContent() {
		var divBussinessContent = jQuery("#bussinessContent");
		var identify = jQuery("#identify").val();
//		divBussinessContent.empty();
		if ("" != identify) {
			var url = window.rootPath
					+ '/ui/bussinessmain/getBussinesserContent/' + identify;
			jQuery
					.ajax({
						type : 'get',
						url : url,
						data : "",
						dataType : 'json',
						contentType : 'application/json;charset=utf-8',
						success : function(data) {
							if (data.code == 1) {
								var bussinessContent = data.data.BussinessContent.bussinessContent;
								divBussinessContent.append(bussinessContent);
								// var tabContent = jQuery("#contenttab");
								// tabContent.table('refresh');

								var divWidth = divBussinessContent.width();
								oldDIVWidth = divWidth;
								var scale = divWidth / 1000;
								jQuery("#bussinessContent table").removeAttr(
										"width");
								jQuery("#bussinessContent tr").removeAttr(
										"width");
								jQuery("#bussinessContent th").removeAttr(
										"width");
								jQuery("#bussinessContent td").removeAttr(
										"width");
								// 缩放
								jQuery("#bussinessContent img")
										.each(
												function() {
													var oWidth = $(this)
															.width();
													var oHeight = $(this)
															.height();
													if (oHeight != 0) {
														$(this).width(
																oWidth * scale);
														$(this)
																.height(
																		oHeight
																				* scale);
													} else {
														$(this).width(
																divWidth * 0.5);
													}
													$(this)
															.prop("href",
																	"#bussinessContentPop");
													$(this).prop("data-rel",
															"popup");
													$(this).prop(
															"data-position-to",
															"window");
													$(this).prop(
															"data-transition",
															"fade");
													$(this)
															.bind(
																	"click",
																	function() {
																		jQuery(
																				"#imgbig")
																				.prop(
																						"src",
																						this.src);
																		// jQuery("#bussinessContentPop").popup("open");
																	});
												})

								/*
								 * setTimeout(function(){
								 * ue.setContent(bussinessContent,false);
								 * },666);
								 */
							}
						}
					});
		}
	}
	;

	// 监听窗体变化
	$(window).resize(function() {
		var divBussinessContent = jQuery("#bussinessContent");
		var divWidth = divBussinessContent.width();
		var scale = divWidth / oldDIVWidth;
		oldDIVWidth = divWidth;
		// 缩放
		jQuery("#bussinessContent img").each(function() {
			var oWidth = $(this).width();
			var oHeight = $(this).height();
			if (oWidth != 50 || oHeight != 0) {
				$(this).width(oWidth * scale);
				$(this).height(oHeight * scale);
			}
		})
	});
})();